#!/usr/bin/python3 
# -*- coding: UTF-8 -*-

from pyfirmata import Arduino
import time,platform

if platform.system()=="Windows":
    # windows的端口号
    board = Arduino('COM6')
elif platform.system() =="Linux":
    # linux的端口,查看方法 ll /dev/tty 然后按住Tab键补全下  结果：/dev/ttyACM0
    # sudo usermod -aG dialout 用户名    
    board = Arduino('/dev/ttyUSB0')


while True:
    print("开灯")
    board.digital[12].write(1) #向端口13写入0   0代表灭灯
    board.digital[13].write(0) #向端口13写入0   0代表灭灯
    # time.sleep(2)
    board.pass_time(2)
    print("关灯")
    board.digital[12].write(0) #向端口13写入1   1代表亮灯
    board.digital[13].write(1) #向端口13写入1   1代表亮灯
    time.sleep(2)